package com.shop2cn.iapi.accounting.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 出入账接口接口Call FreeMaker Template自动生成代码
 */
public class AccountingCall extends YmatouBaseCall {
	private static String opurl = "api/Account/Accounting";
	
	public AccountingCall() {
		super(EnvSetup.getSystemUrl("sqaccounting_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	// 获取 Status
	public int getStatus() {
		int status = 0;
		try {
			status = new JSONObject(getReturnData()).getInt("StatusCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return status;
	}

	// 获取 Msg
	public String getMsg() {
		String message = null;
		try {
			message = new JSONObject(getReturnData()).getString("Message");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return message;
	}
}